package helper;

import essenceClasses.CurrentTask;
import essenceClasses.Task;
import essenceClasses.User;
import model.TaskState;
import service.CurrentTaskService;
import service.TaskService;

import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: user
 * Date: 09.06.14
 * Time: 10:51
 * To change this template use File | Settings | File Templates.
 */
public class TaskHelper {
    private TaskService taskService;
    private CurrentTaskService currentTaskService;
    private String title;
    private String description;
    private int priority;
    private Date createDate;
    private Date startDate;
    private Date endDate;





    public TaskHelper() {

        this.taskService = new TaskService();
        this.currentTaskService = new CurrentTaskService();


    }


    public List<Task> getAllTask(int access) {
        if(access==1){
        List<Task> list = null;
        try {
            list = taskService.getAllTasks();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return list;
    }
    else return null;}

    public List<CurrentTask> getCurrentTaskByTaskId(int id){
        List<CurrentTask> list = null;
        Task task = null;
        try {
            list = currentTaskService.getCurrentTasksById(task.getId());
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return list;
    }

    public List<CurrentTask> getCurrentTaskByRecepientId(int id){
        List<CurrentTask> list = null;
        User user = null;
        try {
            list = currentTaskService.getCurrentTasksByRecepientId(id);
        } catch (SQLException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
        return list;
    }

    public List<CurrentTask> getCurrentTaskByState(TaskState ts){
        List<CurrentTask> list = null;
        try {
            list = currentTaskService.getCurrentTaskByState(ts);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return list;
    }

   public boolean addTask (String title, String description, int priority, java.sql.Date createDate, java.sql.Date startDate, java.sql.Date endDate){
       boolean task ;
       try {
           task= taskService.addTask(title, description,priority, createDate, startDate, endDate);
       } catch (SQLException e) {
           e.printStackTrace();
       }

       return true;
   }

}
